package 并发编程;

import org.openjdk.jol.info.ClassLayout;

public class JolDemo {
    Object o = new Object();
    public static void main(String[] args) {
        JolDemo jol = new JolDemo();
//        OFFSET  SIZE               TYPE DESCRIPTION                               VALUE
//        0     4                    (object header)                           01 00 00 00 (00000001 00000000 00000000 00000000) (1)
//        4     4                    (object header)                           00 00 00 00 (00000000 00000000 00000000 00000000) (0)
//        8     4                    (object header)                           05 c1 00 f8 (00000101 11000001 00000000 11111000) (-134168315)
//        12     4   java.lang.Object JolDemo.o                                 (object)
//        Instance size: 16 bytes
//        Space losses: 0 bytes internal + 0 bytes external = 0 bytes total
        System.out.println(ClassLayout.parseInstance(jol).toPrintable());
        synchronized (jol) {
//            OFFSET  SIZE               TYPE DESCRIPTION                               VALUE
//            0     4                    (object header)                           38 f4 90 02 (00111000 11110100 10010000 00000010) (43054136)
//            4     4                    (object header)                           00 00 00 00 (00000000 00000000 00000000 00000000) (0)
//            8     4                    (object header)                           05 c1 00 f8 (00000101 11000001 00000000 11111000) (-134168315)
//            12     4   java.lang.Object JolDemo.o                                 (object)
//            Instance size: 16 bytes
//            Space losses: 0 bytes internal + 0 bytes external = 0 bytes total
            System.out.println(ClassLayout.parseInstance(jol).toPrintable());
        }
    }
}
